package easy;

import java.util.ArrayList;
import java.util.List;

public class Solution_2032 {

    public List<Integer> twoOutOfThree(int[] nums1, int[] nums2, int[] nums3) {
        int[] flags_1 = new int[101];
        int[] flags_2 = new int[101];
        int[] flags_3 = new int[101];
        for (int num : nums1) {
            flags_1[num] = 1;
        }
        for (int num : nums2) {
            flags_2[num] = 2;
        }
        for (int num : nums3) {
            flags_3[num] = 4;
        }
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 101; i++) {
            int num = flags_1[i] | flags_2[i] | flags_3[i];
            int count = Integer.bitCount(num);
            if (count >= 2) {
                list.add(i);
            }
        }
        return list;
    }
}
